<?php 
$attributes = array('id' => 'round_form');
echo form_open('round/saveround', $attributes); ?>

<table width="100%">
    <tr>
        <td class="menuActual">Config > Users > New Round</td>
    </tr>
    <tr>
        <td>
            <span id='round_form_msg' class="msg_error">* Required fields</span>
            <table>             
            <?php
            if(!isset($ronda)) $ronda = new Round_dto();
            echo form_input(array('name' => 'id', 'type'=>'hidden', 'id' =>'id_round', 'value' => $ronda->id));
            //echo form_hidden('id', $ronda->id);
            ?>
                <tr>
                    <td  class="descripcionForm"><?php echo form_label("Name: *");?></td>
                    <td  class="descripcionForm">
                        <?php
                        $attributes = array('id' => 'nameRound', 'size' => '20','name' => 'nameRound', 'maxlength' => '50', 
                        'value' => (set_value('nameRound') == '' ? $ronda->name : set_value('nameRound')));
                        echo form_input($attributes);
                        ?>
                    </td>
                </tr>
                
                <tr>
                    <td class="descripcionForm"><?php echo form_label("Start Date: *");?></td>
                    <td class="descripcionForm">
                    <?php
                    $attributes = array('id' => 'startDateRound', 'size' => '10','name' => 'startDateRound', 'maxlength' => '10', 'readonly' => TRUE, 'onfocus' => "displayCalendar(document.forms[1].startDateRound,'yyyy/mm/dd',this)", 'placeholder' => '2013/09/23',
                        'value' => (set_value('startDateRound') == '' ? $ronda->startDate : set_value('startDateRound')));
                    echo form_input($attributes);
                    ?>
                    </td>
                </tr>
                
                <tr>
                    <td class="descripcionForm"><?php echo form_label("End Date: *"); ?> </td>
                    <td class="descripcionForm">
                    <?php
                    $attributes = array('id' => 'endDateRound', 'size' => '10','name' => 'endDateRound', 'maxlength' => '10', 'readonly' => TRUE, 'onfocus' => "displayCalendar(document.forms[1].endDateRound,'yyyy/mm/dd',this)", 'placeholder' => '2013/09/23',
                        'value' => (set_value('endDateRound') == '' ? $ronda->endDate : set_value('endDateRound')));
                    echo form_input($attributes);
                    ?>
                    </td>
                </tr>

                <?php 
                // Sólo doy la opción de copiar las BL desde otra ronda, cuando se trata de una nueva
                if($ronda->id == 0) { ?>
                <tr>
                    <td class="descripcionForm"><?php echo form_label("Copy Business Lines from:"); ?></td>
                    <td class="descripcionForm">
                        <?php
                        $opcionesRound = array();
                        $opcionesRound[] = '';
                        $defaultSelection = 0;
                        if(isset($rounds)){
                            foreach ($rounds as $rnd) {
                                $nombreRound_cortado = strlen($rnd->name) > 50 ? substr($rnd->name, 0, 50) . ' (...)' : $rnd->name;
                                $opcionesRound[$rnd->id] = $nombreRound_cortado;
                            }
                        
                            echo form_dropdown('roundCopy', $opcionesRound, $defaultSelection, 'id = roundCopy');
                        }
                        ?>
                    </td>
                </tr>
                <?php } ?>
                <tr>
                    <td class="descripcionForm" colspan="2"><?php echo validation_errors(); ?></td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<?php echo form_close();?>